using System;

namespace Lichtspiel.ECSystem.Behaviors
{
    public class BehaviorComposite : BehaviorHolder
    {
        public BehaviorComposite()
            : base() { }

        public BehaviorComposite(Action finished)
            : base(finished) {}

        public override void Update(GameTime time) {
            base.Update(time);

            for (int i = behaviors.Count - 1; i >= 0; i--) {
                behaviors[i].Update(time);
            }
        }

        protected override void Initialize() {
            base.Initialize();

            foreach (Behavior b in behaviors) {
                b.Initialize(owner, this);
            }
        }
    }
}